# Maintainer: David Runge <dvzrv@archlinux.org>

_name=micawber
pkgname=python-micawber
pkgver=0.5.4
pkgrel=4
pkgdesc="A small library for extracting rich content from urls."
arch=('any')
url="https://github.com/coleifer/micawber"
license=('MIT')
depends=('python')
makedepends=('python-setuptools')
checkdepends=('python-pytest' 'python-beautifulsoup4' 'python-django')
optdepends=('python-django: django support'
            'python-flask: flask support'
            'python-redis: redis caching support')
source=("https://files.pythonhosted.org/packages/source/${_name::1}/${_name}/${_name}-${pkgver}.tar.gz")
sha512sums=('7419af024de7a917d8fc8aea75cb2cbb9f03f5fce73e040a420f7ffd3f950e5717348a252f9716b42bf979757f5ba43d82239a88df5f904964b2157f179aac8e')
b2sums=('cc31aaa6b72ad4c4d1032792a3748d95edda2af2e233dc69f362d25d2cda8ddf25ca7b9fdaea71685c7fa9bf3eaf571bec748451eba1b913477d0490c63b3334')

prepare() {
  mv -v "${_name}-$pkgver" "$pkgname-$pkgver"
}

build() {
  cd "$pkgname-$pkgver"
  python setup.py build
}

check() {
  cd "$pkgname-$pkgver"
  export PYTHONPATH="build/lib:${PYTHONPATH}"
  python runtests.py
}

package() {
  cd "$pkgname-$pkgver"
  python setup.py install --skip-build \
                          --optimize=1 \
                          --root="${pkgdir}"
  install -vDm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"
  install -vDm 644 README.rst -t "${pkgdir}/usr/share/doc/${pkgname}"
}
